package server

import (
	"os"
	"yybk/api"
	"yybk/middleware"

	"github.com/gin-gonic/gin"
)

// NewRouter 路由配置
func NewRouter() *gin.Engine {
	r := gin.Default()

	// 中间件, 顺序不能改
	r.Use(middleware.Session(os.Getenv("SESSION_SECRET")))
	r.Use(middleware.Cors())
	//r.Use(middleware.CurrentUser())

	// 路由
	ping := r.Group("/test")
	{
		ping.GET("/ping", api.Ping)
		ping.POST("/ping", api.Ping)
	}

	v1 := r.Group("/v1")
	{
		v1.POST("/teacher/responder/submit", api.DoResponder.Submit)
		v1.POST("/teacher/responder/stop", api.DoResponder.Stop)
	}

	return r
}
